home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-01.zip / 01 / Hity z okladki / OrgPlus 6 SBE / ORGPL.CAB / toolbar.htc < prev    next >
Text File  |  2006-09-20  |  55KB  |  2,075 lines

  1. <public:component tagname="Toolbar" literalcontent="true">
  2. <public:method name="createLabelAt" internalname="f_PublicCreateLabelAt" />
  3. <public:method name="createButtonAt" internalname="f_PublicCreateButtonAt" />
  4. <public:method name="createCheckButtonAt" internalname="f_PublicCreateCheckButtonAt" />
  5. <public:method name="createSeparatorAt" internalname="f_PublicCreateSeparatorAt" />
  6. <public:method name="createGripperAt" internalname="f_PublicCreateGripperAt" />
  7. <public:method name="createTextBoxAt" internalname="f_PublicCreateTextBoxAt" />
  8. <public:method name="createDropDownListAt" internalname="f_PublicCreateDropDownListAt" />
  9. <public:method name="createCheckGroupAt" internalname="f_PublicCreateCheckGroupAt" />
  10. <public:method name="getItem" internalname="f_PublicGetItem" />
  11. <public:property name="numItems" get="f_PublicGetCount" />
  12. <public:property name="defaultStyle" id="prDefaultStyle" get="get_defaultStyle" put="set_defaultStyle" />
  13. <public:property name="hoverStyle" id="prHoverStyle" get="get_hoverStyle" put="set_hoverStyle" />
  14. <public:property name="selectedStyle" id="prSelectedStyle" get="get_selectedStyle" put="set_selectedStyle" />
  15. <public:property name="movement" id="prMovement" get="get_movement" put="set_movement" />
  16. <public:property name="orientation" id="prOrientation" get="get_orientation" put="set_orientation" />
  17. <public:property name="turnVerticalContent" id="prTurnVerticalContent" get="get_turnVerticalContent" put="set_turnVerticalContent" />
  18. <public:event name="onbuttonclick" id="evButtonClick" />
  19. <public:event name="oncheckchange" id="evCheckChange" />
  20. <public:defaults
  21. tabStop="true"
  22. contentEditable="false"
  23. canHaveHTML="true"
  24. viewInheritStyle="true"
  25. viewMasterTab="false"
  26. viewLinkContent="false"
  27. style="display:none;overflow:visible;cursor:default;padding:1px;background-color:buttonface;border-top:solid 1px buttonhighlight;border-top:solid 1px buttonhighlight;border-left:solid 1px buttonhighlight;border-right:solid 1px buttonshadow;border-bottom:solid 1px buttonshadow"
  28. />
  29.  
  30. <public:attach event="oncontentready" onevent="f_CreateToolbar()" />
  31. <public:attach event="onpropertychange" onevent="f_OnPropertyChange()" />
  32. <public:attach event="ondocumentready" onevent="f_OnDocReady()" />
  33.  
  34. <script language="JScript">
  35.  
  36. var _oTable;
  37. var _oInteractNode;
  38. var _OnStopCount = 0;
  39. var _Ready = false;
  40. var _bDragging = false;
  41. var _bDocked = false;
  42. var _szDockedLocation = "";
  43. var _nLastClientX;
  44. var _nLastClientY;
  45. var _nLastScreenX;
  46. var _nLastScreenY;
  47. var _tbDefaultStyle = "";
  48. var _tbHoverStyle = "";
  49. var _tbSelectedStyle = "";
  50. var _Orientation = "horizontal";
  51. var _TurnVerticalContent = false;
  52. var _Movement = "";
  53. var _KeyboardClick = false;
  54. var _PreDockOrientation = "";
  55. var _IsSubmitting = false;
  56. var _BuiltInDefaultStyle = "color:buttontext;padding:2px;border:solid 1px buttonface";
  57. var _BuiltInHoverStyle = "border-top-color:buttonhighlight;border-left-color:buttonhighlight;border-bottom-color:buttonshadow;border-right-color:buttonshadow";
  58. var _BuiltInSelectedStyle = "border-top-color:buttonshadow;border-left-color:buttonshadow;border-bottom-color:buttonhighlight;border-right-color:buttonhighlight;padding-top:3px;padding-left:3px;padding-bottom:1px;padding-right:1px";
  59. var _szSeparatorHorizStyle = "border-left-width:1px;border-left-style:solid;border-left-color:#a6a6a6;margin-left:2px;margin-right:2px;width:1px;overflow:hidden;";
  60. var _szSeparatorVertStyle = "border-top-width:1px;border-top-style:solid;border-top-color:buttonshadow;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:buttonhighlight;margin-top:2px;margin-bottom:2px;margin-left:3px;margin-right:3px;height:2px;overflow:hidden;";
  61. var _szGripperHorizStyle = "cursor:move;margin-left:2px;margin-right:2px;border-top:buttonhighlight;border-bottom:buttonshadow;border-right:buttonshadow;border-left:buttonhighlight;border-style:solid;border-width:1px;width:3px;overflow:hidden;";
  62. var _szGripperVertStyle = "cursor:move;margin-top:2px;margin-bottom:2px;margin-left:3px;margin-right:3px;border-top:buttonhighlight;border-bottom:buttonshadow;border-right:buttonshadow;border-left:buttonhighlight;border-style:solid;border-width:1px;height:3px;overflow:hidden;";
  63.  
  64. function f_GetParent()
  65. {
  66.   if (_oTable.children[0] == null)
  67.   {
  68.     return;
  69.   }
  70.   if (orientation == "vertical")
  71.   {
  72.     return _oTable.children[0];
  73.   }
  74.   else
  75.   {
  76.     if (_oTable.children[0].children.length > 0)
  77.       return _oTable.children[0].children[0];
  78.   }
  79. }
  80.  
  81. function get_orientation()
  82. {
  83.   return _Orientation;
  84. }
  85.  
  86. function set_orientation(value)
  87. {
  88.   var szOrig = _Orientation;
  89.   if (typeof value == "string")
  90.   {
  91.     var lVal = value.toLowerCase();
  92.     switch (lVal)
  93.     {
  94.       case "horizontal":
  95.       case "vertical":
  96.       _Orientation = lVal;
  97.      break;
  98.     }
  99.   }
  100.  
  101.   if (_Ready && (szOrig != _Orientation))
  102.   {
  103.     if (_Orientation == "horizontal")
  104.       f_RearrangeHorizontal();
  105.     else
  106.       f_RearrangeVertical();
  107.     prOrientation.fireChange();
  108.   }
  109. }
  110.  
  111. function f_RearrangeHorizontal()
  112. {
  113.   var root = _oTable.children[0];
  114.   if (root.children.length == 0)
  115.   {
  116.     root.appendChild(element.document.createElement("TR"));
  117.     return;
  118.   }
  119.   var topRow = root.children[0];
  120.   if (topRow.children.length > 0)
  121.   {
  122.     var item = topRow.children[0];
  123.     f_AdjustContents(item);
  124.     f_AdjustSeps(item);
  125.   }
  126.  
  127.   while (root.children.length > 1)
  128.   {
  129.     var item = topRow.appendChild(root.children[1].children[0]);
  130.     f_AdjustContents(item);
  131.     f_AdjustSeps(item);
  132.     root.children[1].removeNode(true);
  133.   }
  134.  
  135.   f_ApplyStylesToChildren();
  136. }
  137.  
  138. function f_RearrangeVertical()
  139. {
  140.   var root = _oTable.children[0];
  141.   if (root.children.length == 0)
  142.     return;
  143.   var oldRow = root.children[0];
  144.   if (oldRow.children.length == 0)
  145.   {
  146.     oldRow.removeNode(true);
  147.     return;
  148.   }
  149.  
  150.   if (oldRow.children.length > 0)
  151.   {
  152.     var item = oldRow.children[0];
  153.     f_AdjustContents(item);
  154.     f_AdjustSeps(item);
  155.    }
  156.  
  157.    while (oldRow.children.length > 1)
  158.    {
  159.      var row = element.document.createElement("TR");
  160.      if (item._type == "emptygroup")
  161.      row.style.display = "none";
  162.      root.appendChild(row);
  163.      var item = row.appendChild(oldRow.children[1]);
  164.      f_AdjustContents(item);
  165.      f_AdjustSeps(item);
  166.    }
  167.    f_ApplyStylesToChildren();
  168. }
  169.  
  170. function f_AdjustSeps(item)
  171. {
  172.   if ((item._type != "separator") && (item._type != "gripper"))
  173.     return;
  174.   var builtIn;
  175.   if ((element.style.writingMode != null) && (element.style.writingMode == "tb-rl"))
  176.   {
  177.     if (item._type == "separator")
  178.       builtIn = (orientation == "vertical") ? _szSeparatorHorizStyle : _szSeparatorVertStyle;
  179.     else
  180.       builtIn = (orientation == "vertical") ? _szGripperHorizStyle : _szGripperVertStyle;
  181.   }
  182.   else
  183.   {
  184.     if (item._type == "separator")
  185.       builtIn = (orientation == "vertical") ? _szSeparatorVertStyle : _szSeparatorHorizStyle;
  186.     else
  187.       builtIn = (orientation == "vertical") ? _szGripperVertStyle : _szGripperHorizStyle;
  188.   }
  189.   item.children[0].style.cssText = builtIn + ";" + item.children[0]._origStyle;
  190. }
  191.  
  192. function get_turnVerticalContent()
  193. {
  194.   return _TurnVerticalContent;
  195. }
  196.  
  197. function set_turnVerticalContent(value)
  198. {
  199.   var bOrig = _TurnVerticalContent;
  200.   if (typeof value == "boolean")
  201.   {
  202.     _TurnVerticalContent = value;
  203.   }
  204.   else if (typeof value == "string")
  205.   {
  206.     var lVal = value.toLowerCase();
  207.     _TurnVerticalContent = (lVal != "false") && (lVal != "no") && (lVal != "0");
  208.   }
  209.   if (_Ready && (bOrig != _TurnVerticalContent))
  210.   {
  211.     if (_Orientation == "vertical")
  212.       f_RearrangeVerticalContent();
  213.     prTurnVerticalContent.fireChange();
  214.   }
  215. }
  216.  
  217. function f_RearrangeVerticalContent()
  218. {
  219.   var root = _oTable.children[0];
  220.   if (root.children.length == 0)
  221.     return;
  222.   for (var row = 0; row < root.children.length; row++)
  223.   {
  224.     f_AdjustContents(root.children[row].children[0]);
  225.   }
  226.   f_ApplyStylesToChildren();
  227. }
  228.  
  229. function get_defaultStyle()
  230. {
  231.   return _tbDefaultStyle;
  232. }
  233.  
  234. function set_defaultStyle(value)
  235. {
  236.   var orig = _tbDefaultStyle;
  237.   if (typeof value == "string")
  238.   {
  239.     _tbDefaultStyle = value;
  240.     if (_Ready)
  241.       f_ApplyStylesToChildren();
  242.   }
  243.   if (_Ready && (orig != _tbDefaultStyle))
  244.   {
  245.     prDefaultStyle.fireChange();
  246.   }
  247. }
  248.  
  249. function get_hoverStyle()
  250. {
  251.   return _tbHoverStyle;
  252. }
  253.  
  254. function set_hoverStyle(value)
  255. {
  256.   var orig = _tbHoverStyle;
  257.   if (typeof value == "string")
  258.   {
  259.     _tbHoverStyle = value;
  260.     if (_Ready)
  261.       f_ApplyStylesToChildren();
  262.   }
  263.   if (_Ready && (orig != _tbHoverStyle))
  264.   {
  265.     prHoverStyle.fireChange();
  266.   }
  267. }
  268.  
  269. function get_selectedStyle()
  270. {
  271.   return _tbSelectedStyle;
  272. }
  273.  
  274. function set_selectedStyle(value)
  275. {
  276.   var orig = _tbSelectedStyle;
  277.   if (typeof value == "string")
  278.   {
  279.     _tbSelectedStyle = value;
  280.     if (_Ready)
  281.       f_ApplyStylesToChildren();
  282.   }
  283.   if (_Ready && (orig != _tbSelectedStyle))
  284.   {
  285.     prSelectedStyle.fireChange();
  286.   }
  287. }
  288.  
  289. function get_movement()
  290. {
  291.   return _Movement;
  292. }
  293.  
  294. function set_movement(value)
  295. {
  296.   var szOrig = _Movement;
  297.   if (typeof value == "string")
  298.   {
  299.     var lVal = value.toLowerCase();
  300.     switch (lVal)
  301.     {
  302.     case "move":
  303.     case "move-dock":
  304.     case "":
  305.       _Movement = lVal;
  306.       break;
  307.     case "none":
  308.       _Movement = "";
  309.       break;
  310.     }
  311.   }
  312.   if (_Ready && (szOrig != _Movement))
  313.   {
  314.     if (f_IsMoveable())
  315.     {
  316.       defaults.style.position = "absolute";
  317.       defaults.style.zIndex = "1";
  318.       defaults.style.overflow = "hidden";
  319.     }
  320.     else
  321.     {
  322.       defaults.style.position = "static";
  323.       defaults.style.zIndex = "";
  324.       defaults.style.overflow = "visible";
  325.     }
  326.     prMovement.fireChange();
  327.   }
  328. }
  329.  
  330. function f_IsMoveable()
  331. {
  332.   switch (_Movement)
  333.   {
  334.   case "move":
  335.   case "move-dock":
  336.     return true;
  337.   }
  338.   return false;
  339. }
  340.  
  341. function f_IsDockable()
  342. {
  343.   return (_Movement == "move-dock");
  344. }
  345.  
  346. function f_PublicCreateLabelAt(index)
  347. {
  348.   return f_AddItemAt(index, "<ie:ToolbarLabel />");
  349. }
  350.  
  351. function f_PublicCreateButtonAt(index)
  352. {
  353.   return f_AddItemAt(index, "<ie:ToolbarButton />");
  354. }
  355.  
  356. function f_PublicCreateCheckButtonAt(index)
  357. {
  358.   return f_AddItemAt(index, "<ie:ToolbarCheckButton />");
  359. }
  360.  
  361. function f_PublicCreateSeparatorAt(index)
  362. {
  363.   return f_AddItemAt(index, "<ie:ToolbarSeparator />");
  364. }
  365.  
  366. function f_PublicCreateGripperAt(index)
  367. {
  368.   return f_AddItemAt(index, "<ie:ToolbarGripper />");
  369. }
  370.  
  371. function f_PublicCreateDropDownListAt(index)
  372. {
  373.   return f_AddItemAt(index, "<ie:ToolbarDropDownList />");
  374. }
  375.  
  376. function f_PublicCreateTextBoxAt(index)
  377. {
  378.   return f_AddItemAt(index, "<ie:ToolbarTextBox />");
  379. }
  380.  
  381. function f_PublicCreateCheckGroupAt(index)
  382. {
  383.   return f_AddItemAt(index, "<ie:ToolbarCheckGroup />");
  384. }
  385.  
  386. function f_AddItemAt(index, html)
  387. {
  388.   var numItems = f_NumItems();
  389.   var realIndex = f_PublicToRealIndex(index);
  390.   if ((realIndex < 0) || (realIndex > numItems))
  391.   {
  392.     realIndex = numItems;
  393.     index = f_PublicGetCount();
  394.   }
  395.   f_AddItemAtRealIndex(realIndex, html);
  396.   return f_PublicGetItem(index);
  397. }
  398.  
  399. function f_AddItemToGroupAt(index, group, publicGroup)
  400. {
  401.   var parent = f_GetParent();
  402.   if (parent == null)
  403.     return null;
  404.  
  405.   var numInGroup = publicGroup.getCount();
  406.   if ((index < 0) || (index > numInGroup))
  407.     index = numInGroup;
  408.  
  409.   var realIndex = 0;
  410.   var cell;
  411.   var foundGroup = false;
  412.   for (realIndex = 0; realIndex < parent.children.length; realIndex++)
  413.   {
  414.     cell = parent.children[realIndex];
  415.     if ((orientation == "vertical") && (cell.children.length > 0))
  416.       cell = cell.children[0];
  417.     if (((cell._type == "checkbutton") || (cell._type == "emptygroup")) && (cell._group != null))
  418.     {
  419.       if (group == cell._group)
  420.       {
  421.         foundGroup = true;
  422.         break;
  423.       }
  424.     }
  425.   }
  426.  
  427.   if (!foundGroup)
  428.     return null;
  429.  
  430.   var selectItem = false;
  431.   if (cell._type == "emptygroup")
  432.   {
  433.     if (orientation == "vertical")
  434.       cell = cell.parentElement;
  435.     cell.removeNode(true);
  436.     selectItem = group.bForceSel;
  437.   }
  438.  
  439.   var newIndex = realIndex + index;
  440.   var newItem = f_AddItemAtRealIndex(newIndex, "<ie:ToolbarCheckButton />");
  441.   newItem._group = group;
  442.   newItem.id = newItem.uniqueID;
  443.   var publicNewItem = publicGroup.getItem(index);
  444.  
  445.   if (selectItem && (publicNewItem != null))
  446.     publicNewItem.setAttribute("selected", "true");
  447.  
  448.   return publicNewItem;
  449. }
  450.  
  451. function f_AddItemAtRealIndex(index, html)
  452. {
  453.   var parent = f_GetParent();
  454.   if (parent == null)
  455.     return null;
  456.  
  457.   var aNodes = f_CreateNodesFromHtml(html);
  458.   if ((aNodes == null) || (aNodes.length < 1))
  459.     return null;
  460.  
  461.   var cell = aNodes[0];
  462.   var retCell = cell;
  463.   if (orientation == "vertical")
  464.   {
  465.     var trRow = element.document.createElement("TR");
  466.     if (cell._type == "emptygroup")
  467.       trRow.style.display = "none";
  468.  
  469.     trRow.appendChild(cell);
  470.     cell = trRow;
  471.   }
  472.   if (index == f_NumItems())
  473.   {
  474.     parent.appendChild(cell);
  475.   }
  476.   else
  477.   {
  478.     parent.children[index].insertAdjacentElement("beforeBegin", cell);
  479.   }
  480.   f_ApplyStylesToChildren();
  481.   return retCell;
  482. }
  483.  
  484. function f_PublicToRealIndex(index)
  485. {
  486.   var parent = f_GetParent();
  487.   if ((parent == null) || (parent.children.length == 0))
  488.     return -1;
  489.  
  490.   var curIndex = -1;
  491.   var realIndex;
  492.   var cell;
  493.   var group = null;
  494.   for (realIndex = 0; realIndex < parent.children.length; realIndex++)
  495.   {
  496.     cell = parent.children[realIndex];
  497.     if ((orientation == "vertical") && (cell.children.length > 0))
  498.       cell = cell.children[0];
  499.  
  500.     if (((cell._type == "checkbutton") || (cell._type == "emptygroup")) && (cell._group != null))
  501.     {
  502.       if (group != cell._group)
  503.       {
  504.         curIndex++;
  505.         group = cell._group;
  506.       }
  507.     }
  508.     else
  509.     {
  510.       group = null;
  511.       curIndex++;
  512.     }
  513.  
  514.     if (curIndex == index)
  515.     return realIndex;
  516.   }
  517.   return -1;
  518. }
  519.  
  520. function f_PublicGetCount()
  521. {
  522.   var parent = f_GetParent();
  523.   if ((parent == null) || (parent.children.length == 0))
  524.     return 0;
  525.  
  526.   var numItems = 0;
  527.   var realIndex;
  528.   var cell;
  529.   var group = null;
  530.   for (realIndex = 0; realIndex < parent.children.length; realIndex++)
  531.   {
  532.     cell = parent.children[realIndex];
  533.     if ((orientation == "vertical") && (cell.children.length > 0))
  534.       cell = cell.children[0];
  535.  
  536.     if (((cell._type == "checkbutton") || (cell._type == "emptygroup")) && (cell._group != null))
  537.     {
  538.       if (group != cell._group)
  539.       {
  540.         numItems++;
  541.         group = cell._group;
  542.       }
  543.     }
  544.     else
  545.     {
  546.       group = null;
  547.       numItems++;
  548.     }
  549.   }
  550.   return (numItems < 0) ? 0 : numItems;
  551. }
  552.  
  553. function f_PublicGetItem(index)
  554. {
  555.   if ((index < 0) || (index > f_NumItems()))
  556.     return null;
  557.  
  558.   var realIndex = f_PublicToRealIndex(index);
  559.   var item = f_GetItem(realIndex);
  560.   if (item == null)
  561.     return null;
  562.  
  563.   if (((item._type == "checkbutton") || (item._type == "emptygroup")) && (item._group != null))
  564.     return f_PublicMakeGroupContract(item);
  565.   else
  566.     return f_PublicMakeContract(item);
  567. }
  568.  
  569. function f_PublicMakeContract(item)
  570. {
  571.   var obj = new Object();
  572.   obj.getType = function() { return item._type; };
  573.  
  574.   if ((item._type == "dropdownlist") || (item._type == "textbox"))
  575.   {
  576.     obj.click = function() { item.children[0].click(); };
  577.     obj.focus = function() { item.children[0].focus(); };
  578.     obj.blur = function() { item.children[0].blur(); };
  579.   }
  580.   else
  581.   {
  582.     obj.click = function() { item.click(); };
  583.     obj.focus = function() { item.focus(); };
  584.     obj.blur = function() { item.blur(); };
  585.   }
  586.  
  587.   obj.remove = function() { f_PublicRemoveItem(item); };
  588.  
  589.   obj.getAttribute = function(name) { return f_PublicGetAttribute(item, name); };
  590.  
  591.   obj.setAttribute = function(name, value) { f_PublicSetAttribute(item, name, value); };
  592.  
  593.   if (item._type == "dropdownlist")
  594.     obj.getOptions = function() { return item.children[0].options; };
  595.  
  596.   return obj;
  597. }
  598.  
  599. function f_PublicMakeGroupContract(item)
  600. {
  601.   var obj = new Object();
  602.   obj.getType = function() { return "checkgroup"; };
  603.   obj.getItem = function(subIndex) { return f_PublicGetGroupItem(subIndex, item._group); };
  604.   obj.getSelected = function() { var selItem = _oTable.document.all[item._group.oSelected]; if (selItem != null) return f_PublicMakeContract(selItem); else return null; };
  605.   obj.getAttribute = function(name) { return f_PublicGetGroupAttribute(item._group, name); };
  606.   obj.setAttribute = function(name, value) { f_PublicSetGroupAttribute(item._group, name, value); };
  607.   obj.remove = function() { f_PublicRemoveGroup(item._group); };
  608.   obj.getCount = function() { return f_PublicGetGroupCount(item._group); };
  609.   obj.createCheckButtonAt = function(subIndex) { return f_AddItemToGroupAt(subIndex, item._group, obj); };
  610.   return obj;
  611. }
  612.  
  613. function f_PublicGetGroupCount(group)
  614. {
  615.   var parent = f_GetParent();
  616.   if (parent == null)
  617.     return 0;
  618.  
  619.   var realIndex = 0;
  620.   var count = 0;
  621.   var cell;
  622.   var foundGroup = false;
  623.   for (realIndex = 0; realIndex < parent.children.length; realIndex++)
  624.   {
  625.     cell = parent.children[realIndex];
  626.     if ((orientation == "vertical") && (cell.children.length > 0))
  627.       cell = cell.children[0];
  628.  
  629.     if (((cell._type == "checkbutton") || (cell._type == "emptygroup")) && (cell._group != null))
  630.     {
  631.       if (group == cell._group)
  632.       {
  633.         if (cell._type == "emptygroup")
  634.           return 0;
  635.         count++;
  636.         foundGroup = true;
  637.       }
  638.       else if (foundGroup)
  639.       {
  640.         break;
  641.       }
  642.     }
  643.     else if (foundGroup)
  644.     {
  645.       break;
  646.     }
  647.   }
  648.   return count;
  649. }
  650.  
  651. function f_PublicRemoveGroup(group)
  652. {
  653.   var numItems = f_PublicGetGroupCount(group);
  654.   if (numItems == 0)
  655.   {
  656.     var cell = f_GetGroupItem(0, group);
  657.     if (orientation == "vertical")
  658.       cell = cell.parentElement;
  659.     cell.removeNode(true);
  660.   }
  661.   else
  662.   {
  663.     for (var count = 0; count < numItems; count++)
  664.     {
  665.       var cell = f_GetGroupItem(0, group);
  666.       if (orientation == "vertical")
  667.         cell = cell.parentElement;
  668.       cell.removeNode(true);
  669.     }
  670.   }
  671. }
  672.  
  673. function f_PublicGetGroupItem(index, group)
  674. {
  675.   var item = f_GetGroupItem(index, group);
  676.   if ((item == null) || (item._type == "emptygroup"))
  677.     return null;
  678.  
  679.   return f_PublicMakeContract(item);
  680. }
  681.  
  682. function f_GetGroupItem(index, group)
  683. {
  684.   var parent = f_GetParent();
  685.   if (parent == null)
  686.     return null;
  687.  
  688.   var realIndex = 0;
  689.   var vIndex = -1;
  690.   var cell;
  691.   var foundGroup = false;
  692.   for (realIndex = 0; realIndex < parent.children.length; realIndex++)
  693.   {
  694.     cell = parent.children[realIndex];
  695.     if ((orientation == "vertical") && (cell.children.length > 0))
  696.       cell = cell.children[0];
  697.  
  698.     if (((cell._type == "checkbutton") || (cell._type == "emptygroup")) && (cell._group != null))
  699.     {
  700.       if (group == cell._group)
  701.       {
  702.         foundGroup = true;
  703.         vIndex++;
  704.       }
  705.       else if (foundGroup)
  706.       {
  707.         return null;
  708.       }
  709.       if (vIndex == index)
  710.       {
  711.         return cell;
  712.         break;
  713.       }
  714.     }
  715.     else if (foundGroup)
  716.     {
  717.       return null;
  718.     }
  719.   }
  720.   return null;
  721. }
  722.  
  723. function f_PublicRemoveItem(item)
  724. {
  725.   var empty = null;
  726.   var group = item._group;
  727.   if ((item._type == "checkbutton") && (group != null) && (f_PublicGetGroupCount(group) == 1))
  728.   {
  729.     empty = f_CreateEmptyGroup(group);
  730.   }
  731.  
  732.   if (orientation == "vertical")
  733.   {
  734.     item = item.parentElement;
  735.     if (empty != null)
  736.     {
  737.       var row = element.document.createElement("TR");
  738.       row.style.display = "none";
  739.       row.appendChild(empty);
  740.       empty = row;
  741.     }
  742.   }
  743.  
  744.   if ((group != null) && (group.oSelected == item.uniqueID))
  745.     group.oSelected = null;
  746.  
  747.   if (empty != null)
  748.     item.insertAdjacentElement("beforeBegin", empty);
  749.  
  750.   item.removeNode(true);
  751.  
  752.   if ((group != null) && group.bForceSel && (group.oSelected == null) && (empty == null))
  753.   {
  754.     item = f_PublicGetGroupItem(0, group);
  755.     if (item != null)
  756.     item.setAttribute("selected", "true");
  757.   }
  758. }
  759.  
  760.  
  761. function f_PublicGetGroupAttribute(group, name)
  762. {
  763.   switch (name.toLowerCase())
  764.   {
  765.   case "forceselection":
  766.     return (group.bForceSel) ? "true" : "false";
  767.   case "defaultstyle":
  768.     return group.szDefaultStyle;
  769.   case "hoverstyle":
  770.     return group.szHoverStyle;
  771.   case "selectedstyle":
  772.     return group.szSelectedStyle;
  773.   }
  774. }
  775.  
  776. function f_PublicSetGroupAttribute(group, name, value)
  777. {
  778.   switch (name.toLowerCase())
  779.   {
  780.   case "forceselection":
  781.     group.bForceSel = (value.toLowerCase() == "true");
  782.     if (group.bForceSel && (group.oSelected == null))
  783.     {
  784.       var cell = f_PublicGetGroupItem(0, group);
  785.       if (cell != null)
  786.         cell.setAttribute("selected", "true");
  787.     }
  788.     break;
  789.   case "defaultstyle":
  790.     group.szDefaultStyle = value;
  791.     f_ApplyStylesToChildren();
  792.     break;
  793.   case "hoverstyle":
  794.     group.szHoverStyle = value;
  795.     f_ApplyStylesToChildren();
  796.     break;
  797.   case "selectedstyle":
  798.     group.szSelectedStyle = value;
  799.     f_ApplyStylesToChildren();
  800.     break;
  801.   }
  802. }
  803.  
  804. function f_PublicGetAttribute(item, name)
  805. {
  806.   var lname = name.toLowerCase();
  807.   if ((item._type == "dropdownlist") || (item._type == "textbox"))
  808.   {
  809.     if ((lname != "defaultstyle") && (lname != "style") && (item.children.length > 0))
  810.     item = item.children[0];
  811.   }
  812.  
  813.   if ((lname == "style") && (item.children.length == 1))
  814.     return item.children[0].style.cssText;
  815.  
  816.   return item.getAttribute(name);
  817. }
  818.  
  819. function f_PublicSetAttribute(item, name, value)
  820. {
  821.   var cachedImage;
  822.   var lname = name.toLowerCase();
  823.   if ((item._type == "dropdownlist") || (item._type == "textbox"))
  824.   {
  825.     if ((lname != "defaultstyle") && (lname != "style") && (item.children.length > 0))
  826.       item = item.children[0];
  827.   }
  828.  
  829.   if ((lname != "style") && (lname != "selected") && (lname != "outerhtml") &&
  830.                         (lname != "innertext") && (lname != "innerhtml"))
  831.   {
  832.     item.setAttribute(name, value, 0);
  833.   }
  834.  
  835.   if (!_Ready)
  836.     return;
  837.  
  838.   switch (lname)
  839.   {
  840.   case "defaultstyle":
  841.   case "hoverstyle":
  842.   case "selectedstyle":
  843.     f_ApplyStylesToChildren();
  844.     break;
  845.   case "text":
  846.   case "innertext":
  847.     if ((item._type == "label") || (item._type == "button") || (item._type == "checkbutton"))
  848.     {
  849.       f_DoLabelText(item, value);
  850.     }
  851.     break;
  852.   case "innerhtml":
  853.     if ((item._type == "label") || (item._type == "button") || (item._type == "checkbutton"))
  854.     {
  855.       f_DoLabelHTML(item, value);
  856.     }
  857.     break;
  858.   case "imageurl":
  859.     if ((item._type == "label") || (item._type == "button") || (item._type == "checkbutton"))
  860.     {
  861.       cachedImage = new Image();
  862.       cachedImage.src = value;
  863.       f_DoLabelImageUrl(item, value);
  864.     }
  865.     break;
  866.   case "style":
  867.     if (item.children.length == 1)
  868.     {
  869.       if ((item._type == "separator") || (item._type == "gripper"))
  870.       {
  871.         item.children[0]._origStyle += ";" + value;
  872.       }
  873.       item.children[0].style.cssText += ";" + value;
  874.     }
  875.     break;
  876.   case "selected":
  877.     if (item._type == "checkbutton")
  878.     {
  879.       if (f_IsSelected(item) != (value.toLowerCase() == "true"))
  880.       {
  881.         _KeyboardClick = true;
  882.         item.click();
  883.       }
  884.     }
  885.     break;
  886.   }
  887. }
  888.  
  889.  
  890. function f_DoLabelText(item, text)
  891. {
  892.   f_RemoveTextNodes(item);
  893.   var span = element.document.createElement("SPAN");
  894.   span.innerText = text;
  895.   item.children[0].appendChild(span);
  896.   f_AdjustContents(item);
  897. }
  898.  
  899. function f_DoLabelHTML(item, html)
  900. {
  901.   f_RemoveTextNodes(item);
  902.   var span = element.document.createElement("SPAN");
  903.   span.innerHTML = html;
  904.   item.children[0].appendChild(span);
  905.   f_AdjustContents(item);
  906. }
  907.  
  908. function f_RemoveTextNodes(item)
  909. {
  910.   var content = item.children[0];
  911.   if (content.hasChildNodes())
  912.   {
  913.     var index = (content.getAttribute("_imageAdded")) ? 1 : 0;
  914.     while (index < content.childNodes.length)
  915.       content.childNodes[index].removeNode(true);
  916.   }
  917. }
  918.  
  919. function f_DoLabelImageUrl(item, imageUrl)
  920. {
  921.   var content = item.children[0];
  922.   var imageAdded = content.getAttribute("_imageAdded");
  923.   if (imageAdded && (imageUrl == null))
  924.   {
  925.     content.children[0].removeNode(true);
  926.     content.removeAttribute("_imageAdded", 0);
  927.     if (content.childNodes.length == 0)
  928.     content.innerHTML = " ";
  929.   }
  930.   else if (imageUrl == null)
  931.   {
  932.     return;
  933.   }
  934.   else
  935.   {
  936.     var cacheImage = new Image();
  937.     cacheImage.src = imageUrl;
  938.  
  939.     if (imageAdded == false)
  940.     {
  941.       var img = element.document.createElement("IMG");
  942.       img.src = cacheImage.src;
  943.       if (content.hasChildNodes())
  944.         content.insertBefore(img, content.childNodes[0]);
  945.       else
  946.         content.insertBefore(img);
  947.       content.setAttribute("_imageAdded", "true", 0);
  948.     }
  949.     else
  950.     {
  951.       var img = content.children[0]
  952.       img.src = cacheImage.src;
  953.     }
  954.   }
  955.   f_AdjustContents(item);
  956. }
  957.  
  958. function f_GetItem(nIndex)
  959. {
  960.   var oParent = f_GetParent();
  961.   if (oParent != null)
  962.   {
  963.     if ((nIndex < 0) || (nIndex >= oParent.children.length))
  964.       return null;
  965.     var oCell = oParent.children[nIndex];
  966.     if (orientation == "vertical")
  967.     {
  968.       if (oCell.children.length > 0)
  969.         return oCell.children[0];
  970.     }
  971.     else
  972.     {
  973.       return oCell;
  974.     }
  975.   }
  976.   return null;
  977. }
  978.  
  979. function f_NumItems()
  980. {
  981.   var oParent = f_GetParent();
  982.   if (oParent != null)
  983.   {
  984.     return oParent.children.length;
  985.   }
  986.   return 0;
  987. }
  988.  
  989. function f_OnPropertyChange()
  990. {
  991.   switch (event.propertyName)
  992.   {
  993.   case "innerHTML":
  994.     f_CreateToolbar();
  995.     break;
  996.   case "_submitting":
  997.     _IsSubmitting = (element.getAttribute("_submitting") != null);
  998.     _OnStopCount = 0;
  999.     break;
  1000.   case "style.direction":
  1001.     _oTable.style.direction = element.style.direction;
  1002.     break;
  1003.   case "dir":
  1004.     _oTable.dir = element.dir;
  1005.     break;
  1006.   }
  1007. }
  1008.  
  1009. function f_CreateToolbar()
  1010. {
  1011.   element.document.releaseCapture();
  1012.   f_AddStopEvent();
  1013.   if (f_IsMoveable())
  1014.   {
  1015.     defaults.style.position = "absolute";
  1016.     defaults.style.zIndex = "1";
  1017.     defaults.style.overflow = "hidden";
  1018.   }
  1019.   var oTable = element.document.createElement("TABLE");
  1020.   var oTBody = element.document.createElement("TBODY");
  1021.   _oTable = oTable;
  1022.   oTable.style.fontSize = currentStyle.fontSize;
  1023.   oTable.style.fontFamily = currentStyle.fontFamily;
  1024.   oTable.style.fontWeight = currentStyle.fontWeight;
  1025.   oTable.style.color = currentStyle.color;
  1026.   oTable.cellSpacing = 0;
  1027.   oTable.cellPadding = 0;
  1028.   if (element.currentStyle.direction != element.style.direction)
  1029.     oTable.style.direction = element.currentStyle.direction;
  1030.   else
  1031.     oTable.style.direction = element.style.direction;
  1032.  
  1033.   oTable.dir = element.dir;
  1034.   if (orientation != "vertical")
  1035.   {
  1036.     var oRow = element.document.createElement("TR");
  1037.     oTBody.appendChild(oRow);
  1038.   }
  1039.  
  1040.   oTable.appendChild(oTBody);
  1041.   var aNodes = f_CreateNodesFromHtml(element.innerHTML);
  1042.  
  1043.   for (var nIndex = 0; nIndex < aNodes.length; nIndex++)
  1044.   {
  1045.     f_AppendToolbarItem(aNodes[nIndex]);
  1046.   }
  1047.  
  1048.   f_ApplyStylesToChildren();
  1049.   oTable.attachEvent("onclick", f_OnClick);
  1050.   oTable.attachEvent("ondblclick", f_OnClick);
  1051.   oTable.attachEvent("onmousedown", f_OnMouseDown);
  1052.   oTable.attachEvent("onmouseup", f_OnMouseUp);
  1053.   oTable.attachEvent("onmouseover", f_OnMouseOver);
  1054.   oTable.attachEvent("onmouseout", f_OnMouseOut);
  1055.   oTable.attachEvent("onmousemove", f_Drag);
  1056.   oTable.attachEvent("oncontextmenu", f_CancelInteractEvents);
  1057.   oTable.attachEvent("onselectstart", f_CancelInteractEvents);
  1058.   var oBody = element.document.createElement("BODY");
  1059.   var oHtml = element.document.createElement("HTML");
  1060.   oBody.appendChild(oTable);
  1061.   oHtml.appendChild(oBody);
  1062.   defaults.viewLink = oHtml.document;
  1063.   _Ready = true;
  1064.   defaults.style.display = "block";
  1065. }
  1066.  
  1067.  
  1068. function f_CreateNodesFromHtml(htmlText)
  1069. {
  1070.   var oSpan = element.document.createElement("span");
  1071.   oSpan.innerHTML = htmlText;
  1072.   return f_CreateNodes(oSpan.childNodes);
  1073. }
  1074.  
  1075. function f_CreateNodes(aNodes)
  1076. {
  1077.   var tbNodes = new Array();
  1078.   var nNumNodes = (aNodes == null) ? 0 : aNodes.length;
  1079.   for (var nIndex = 0; nIndex < nNumNodes; nIndex++)
  1080.   {
  1081.     var node = aNodes[nIndex];
  1082.     if (node != null)
  1083.       tbNodes = tbNodes.concat(f_CreateToolbarItems(node));
  1084.   }
  1085.   return tbNodes;
  1086. }
  1087.  
  1088. function f_CreateToolbarItems(oNode)
  1089. {
  1090.   var aNodes;
  1091.   var szTagName = (oNode.tagName == null) ? "" : oNode.tagName.toLowerCase();
  1092.   switch (szTagName)
  1093.   {
  1094.     case "toolbarbutton":
  1095.       aNodes = new Array(f_CreateButton(oNode));
  1096.       break;
  1097.     case "toolbarcheckbutton":
  1098.       aNodes = new Array(f_CreateCheckbutton(oNode));
  1099.       break;
  1100.     case "toolbarseparator":
  1101.       aNodes = new Array(f_CreateSeparator(oNode));
  1102.       break;
  1103.     case "toolbarcheckgroup":
  1104.       aNodes = f_CreateCheckGroup(oNode);
  1105.       break;
  1106.     case "toolbardropdownlist":
  1107.       aNodes = new Array(f_CreateDropDownList(oNode));
  1108.       break;
  1109.     case "toolbartextbox":
  1110.       aNodes = new Array(f_CreateTextBox(oNode));
  1111.       break;
  1112.     case "toolbarlabel":
  1113.       aNodes = new Array(f_CreateLabel(oNode));
  1114.       break;
  1115.     case "toolbargripper":
  1116.       aNodes = new Array(f_CreateGripper(oNode));
  1117.       break;
  1118.     default:
  1119.       aNodes = new Array();
  1120.       break;
  1121.   }
  1122.  
  1123.   for (var nIndex = 0; nIndex < aNodes.length; nIndex++)
  1124.     f_AdjustContents(aNodes[nIndex]);
  1125.   return aNodes;
  1126. }
  1127.  
  1128. function f_Interactable(oCell)
  1129. {
  1130.   switch (oCell._type)
  1131.   {
  1132.   case "checkbutton":
  1133.   case "button":
  1134.     return true;
  1135.   default:
  1136.     return false;
  1137.   }
  1138. }
  1139.  
  1140. function f_IsSelected(oCell)
  1141. {
  1142.   if (oCell._type != "checkbutton")
  1143.     return false;
  1144.   var szSelected = oCell.getAttribute("selected");
  1145.   return ((szSelected != null) && (String(szSelected).toLowerCase() == "true"));
  1146. }
  1147.  
  1148. function f_SetSelected(oCell, bSelected)
  1149. {
  1150.   if (oCell._type != "checkbutton")
  1151.     return;
  1152.   oCell.setAttribute("selected", bSelected ? "true" : "false", 0);
  1153. }
  1154.  
  1155. function f_CheckButton(oSelected)
  1156. {
  1157.   if ((oSelected == null) || (oSelected._type != "checkbutton"))
  1158.     return;
  1159.   if (oSelected._group != null)
  1160.   {
  1161.     var oPrevID = oSelected._group.oSelected;
  1162.     if (oPrevID != null)
  1163.     {
  1164.       var oPrevSel = oSelected.document.all[oPrevID];
  1165.       if (oPrevSel != null)
  1166.       {
  1167.         if (oPrevSel.uniqueID == oSelected.uniqueID)
  1168.           return;
  1169.         f_SetSelected(oPrevSel, false);
  1170.         f_ApplyNeutralStyle(oPrevSel);
  1171.         oSelected._group.oSelected = null;
  1172.         f_FireCheckChange(oPrevSel);
  1173.       }
  1174.     }
  1175.   }
  1176.   f_SetSelected(oSelected, true);
  1177.   f_ApplyNeutralStyle(oSelected);
  1178.   if (oSelected._group != null)
  1179.     oSelected._group.oSelected = oSelected.uniqueID;
  1180.   f_FireCheckChange(oSelected);
  1181. }
  1182.  
  1183. function f_AppendToolbarItem(oCell)
  1184. {
  1185.   var oParent = f_GetParent();
  1186.   if ((oCell == null) || (oParent == null))
  1187.     return;
  1188.   if (orientation == "vertical")
  1189.   {
  1190.     var trRow = element.document.createElement("TR");
  1191.     if (oCell._type == "emptygroup")
  1192.       trRow.style.display = "none";
  1193.     trRow.appendChild(oCell);
  1194.     oParent.appendChild(trRow);
  1195.   }
  1196.   else
  1197.   {
  1198.     oParent.appendChild(oCell);
  1199.   }
  1200. }
  1201.  
  1202. function f_AdjustContents(oCell)
  1203. {
  1204.   if (oCell._turnContent == null)
  1205.     oCell._turnContent = false;
  1206.   var bTurnContent = false;
  1207.   if (turnVerticalContent)
  1208.   {
  1209.     switch (oCell._type)
  1210.     {
  1211.     case "label":
  1212.     case "button":
  1213.     case "checkbutton":
  1214.       bTurnContent = (orientation == "vertical");
  1215.       break;
  1216.     default:
  1217.       return;
  1218.     }
  1219.  
  1220.     if (bTurnContent)
  1221.     {
  1222.       oCell._turnContent = true;
  1223.       oCell.style.writingMode = "tb-rl";
  1224.     }
  1225.   }
  1226.  
  1227.   if (oCell._turnContent && !bTurnContent)
  1228.   {
  1229.     oCell._turnContent = false;
  1230.     oCell.style.writingMode = "lr-tb";
  1231.   }
  1232.  
  1233.   if (oCell._type == "emptygroup")
  1234.     return;
  1235.  
  1236.   var oContent = oCell.children[0];
  1237.   var len = oContent.children.length;
  1238.   for (nIndex = 0; nIndex < len; nIndex++)
  1239.   {
  1240.     var oObj = oContent.children[nIndex];
  1241.     if (oObj.tagName == "IMG")
  1242.     {
  1243.       oObj.align = (bTurnContent) ? "middle" : "absmiddle";
  1244.     }
  1245.   }
  1246. }
  1247.  
  1248. function f_CreateGripper(oNode)
  1249. {
  1250.   var oCell = element.document.createElement("td");
  1251.   var oDiv = element.document.createElement("div");
  1252.   oCell.appendChild(oDiv);
  1253.   var szStyle = "";
  1254.   if ((element.style.writingMode != null) && (element.style.writingMode == "tb-rl"))
  1255.     szStyle = (orientation == "vertical") ? _szGripperHorizStyle : _szGripperVertStyle;
  1256.   else
  1257.     szStyle = (orientation == "vertical") ? _szGripperVertStyle : _szGripperHorizStyle;
  1258.   oDiv._origStyle = oNode.style.cssText;
  1259.   oDiv.style.cssText = szStyle + ";" + oDiv._origStyle;
  1260.   oCell.mergeAttributes(oNode);
  1261.   oCell.id = oNode.getAttribute("id");
  1262.   oCell._type = "gripper";
  1263.   return oCell;
  1264. }
  1265.  
  1266. function f_CreateSeparator(oNode)
  1267. {
  1268.   var oCell = element.document.createElement("TD");
  1269.   var oDiv = element.document.createElement("DIV");
  1270.   oCell.appendChild(oDiv);
  1271.   var szStyle;
  1272.  
  1273.   if ((element.style.writingMode != null) && (element.style.writingMode == "tb-rl"))
  1274.     szStyle = (orientation == "vertical") ? _szSeparatorHorizStyle : _szSeparatorVertStyle;
  1275.   else
  1276.     szStyle = (orientation == "vertical") ? _szSeparatorVertStyle : _szSeparatorHorizStyle;
  1277.  
  1278.   oDiv._origStyle = oNode.style.cssText;
  1279.   oDiv.style.cssText = szStyle + ";" + oDiv._origStyle;
  1280.   oCell.mergeAttributes(oNode);
  1281.   oCell.id = oNode.getAttribute("id");
  1282.   oCell._type = "separator";
  1283.   return oCell;
  1284. }
  1285.  
  1286. function f_CreateButton(oNode)
  1287. {
  1288.   var oCell = f_CreateLabel(oNode);
  1289.   if (oCell.tabIndex == 0)
  1290.     oCell.tabIndex = 1;
  1291.   oCell._type = "button";
  1292.   oCell.attachEvent("onkeyup", f_OnKeyUp);
  1293.   return oCell;
  1294. }
  1295.  
  1296. function f_CreateCheckbutton(oNode)
  1297. {
  1298.   var oCell = f_CreateButton(oNode);
  1299.   oCell._type = "checkbutton";
  1300.   if (oCell.getAttribute("selected") == null)
  1301.     oCell.setAttribute("selected", "flase", 0);
  1302.   return oCell;
  1303. }
  1304.  
  1305. function f_CreateCheckGroup(oNode)
  1306. {
  1307.   var aTempNodes = f_CreateNodesFromHtml(oNode.innerHTML);
  1308.   var aNodes = new Array();
  1309.   var oGroup = new Object();
  1310.   var forceSel = oNode.getAttribute("forceselection");
  1311.   oGroup.bForceSel = (forceSel != null) && (String(forceSel).toLowerCase() == "true");
  1312.   oGroup.oSelected = null;
  1313.   oGroup.szDefaultStyle = oNode.getAttribute("defaultstyle");
  1314.   oGroup.szHoverStyle = oNode.getAttribute("hoverstyle");
  1315.   oGroup.szSelectedStyle = oNode.getAttribute("selectedstyle");
  1316.   var nFirstCheckBtn = -1;
  1317.   var bDisabled = oNode.disabled;
  1318.  
  1319.   for (var nIndex = 0; nIndex < aTempNodes.length; nIndex++)
  1320.   {
  1321.     var oCell = aTempNodes[nIndex];
  1322.     if (oCell._type == "checkbutton")
  1323.     {
  1324.       if (nFirstCheckBtn == -1)
  1325.       nFirstCheckBtn = nIndex;
  1326.       aNodes = aNodes.concat(new Array(oCell));
  1327.       if ((oCell.id == null) || (oCell.id == ""))
  1328.       {
  1329.         oCell.id = oCell.uniqueID;
  1330.       }
  1331.       oCell._group = oGroup;
  1332.       if (f_IsSelected(oCell))
  1333.       {
  1334.         if (oGroup.oSelected == null)
  1335.         {
  1336.           oGroup.oSelected = oCell.uniqueID;
  1337.         }
  1338.         else
  1339.         {
  1340.           f_SetSelected(oCell, false);
  1341.         }
  1342.       }
  1343.     }
  1344.     oCell.disabled = (bDisabled || oCell.isDisabled);
  1345.   }
  1346.  
  1347.   if (oGroup.bForceSel && (oGroup.oSelected == null) && (nFirstCheckBtn != -1))
  1348.   {
  1349.     var oCell = aNodes[nFirstCheckBtn];
  1350.     oGroup.oSelected = oCell.uniqueID;
  1351.     f_SetSelected(oCell, true);
  1352.   }
  1353.  
  1354.   if (aNodes.length == 0)
  1355.     aNodes = new Array(f_CreateEmptyGroup(oGroup));
  1356.   return aNodes;
  1357. }
  1358.  
  1359.  
  1360. function f_CreateEmptyGroup(group)
  1361. {
  1362.   var empty = element.document.createElement("TD");
  1363.   empty._type = "emptygroup";
  1364.   empty._group = group;
  1365.   empty.style.display = "none";
  1366.   return empty;
  1367. }
  1368.  
  1369. function f_CreateLabel(oNode)
  1370. {
  1371.   var oCell = element.document.createElement("TD");
  1372.   var oContent = element.document.createElement("SPAN");
  1373.   oCell.appendChild(oContent);
  1374.   var szText = oNode.getAttribute("text");
  1375.   var szImageUrl = oNode.getAttribute("imageUrl");
  1376.   if (szText == null)
  1377.   {
  1378.     while (oNode.childNodes.length > 0)
  1379.     oContent.appendChild(oNode.childNodes[0].removeNode(true));
  1380.   }
  1381.   else
  1382.   {
  1383.     var oText = element.document.createElement("SPAN");
  1384.     oText.innerText = szText;
  1385.     oContent.appendChild(oText);
  1386.   }
  1387.  
  1388.   if (szImageUrl != null)
  1389.   {
  1390.     var cacheImage = new Image();
  1391.     cacheImage.src = szImageUrl;
  1392.     var oImg = element.document.createElement("IMG");
  1393.     oImg.src = cacheImage.src;
  1394.   
  1395.     var szImageWidth = oNode.getAttribute("img_width");
  1396.     if (szImageWidth != null)
  1397.       oImg.width = szImageWidth;
  1398.  
  1399.     var szImageHeight = oNode.getAttribute("img_height");
  1400.     if (szImageHeight != null)
  1401.       oImg.height = szImageHeight;
  1402.     
  1403.     if (oContent.hasChildNodes())
  1404.       oContent.insertBefore(oImg, oContent.childNodes[0]);
  1405.     else
  1406.       oContent.insertBefore(oImg);
  1407.     oContent.setAttribute("_imageAdded", "true", 0);
  1408.   }
  1409.  
  1410.   if (oContent.childNodes.length == 0)
  1411.     oContent.innerHTML = " ";
  1412.  
  1413.   oCell.mergeAttributes(oNode);
  1414.   oCell.id = oNode.getAttribute("id");
  1415.   oCell.noWrap = "true";
  1416.   oCell._type = "label";
  1417.   oContent.style.cssText = oNode.style.cssText;
  1418.   return oCell;
  1419. }
  1420.  
  1421. function f_CreateTextBox(oNode)
  1422. {
  1423.   var oCell = element.document.createElement("td");
  1424.   var szType = oNode.getAttribute("type");
  1425.   var szValue = oNode.getAttribute("value");
  1426.   var szSize = oNode.getAttribute("size");
  1427.   var szMaxLength = oNode.getAttribute("maxlength");
  1428.   var szReadOnly = oNode.getAttribute("readonly");
  1429.   if ((szType == null) || (szType.toLowerCase() != "password"))
  1430.     szType = "text";
  1431.  
  1432.   var szTabIndex = "1";
  1433.   if (oNode.tabIndex != 0)
  1434.     szTabIndex = oNode.getAttribute("tabindex");
  1435.  
  1436.   oCell.innerHTML = "<input type=\"" + szType + "\">";
  1437.   var textbox = oCell.children[0];
  1438.   textbox.mergeAttributes(oNode);
  1439.  
  1440.   if ((szSize != null) && (szSize != ""))
  1441.     textbox.size = szSize;
  1442.  
  1443.   if ((szMaxLength != null) && (szMaxLength != ""))
  1444.     textbox.maxLength = szMaxLength;
  1445.  
  1446.   if ((szTabIndex != null) && (szTabIndex != ""))
  1447.     textbox.tabIndex = szTabIndex;
  1448.  
  1449.   if ((szValue != null) && (szValue != ""))
  1450.     textbox.value = szValue;
  1451.  
  1452.   if ((szReadOnly != null) && (szReadOnly != ""))
  1453.     textbox.readOnly = szReadOnly;
  1454.  
  1455.   var changeScript = oNode.getAttribute("onchange");
  1456.   if (changeScript != null)
  1457.     textbox.onchange = function() { eval(changeScript) };
  1458.  
  1459.   oCell.id = oNode.getAttribute("id");
  1460.   oCell._type = "textbox";
  1461.   oCell.noWrap = "true";
  1462.   var szDefaultStyle = oNode.getAttribute("defaultStyle");
  1463.   var fontStr = f_CreateFontString(oNode);
  1464.   szDefaultStyle = (szDefaultStyle == null) ? fontStr : fontStr + szDefaultStyle;
  1465.   if (szDefaultStyle != null)
  1466.   {
  1467.     oCell.setAttribute("defaultStyle", szDefaultStyle, 0);
  1468.     oCell.children[0].removeAttribute("defaultStyle", 0);
  1469.   }
  1470.  
  1471.   return oCell;
  1472. }
  1473.  
  1474. function f_CreateFontString(oNode)
  1475. {
  1476.   var fontStr = "";
  1477.   if (oNode.style.fontFamily)
  1478.     fontStr += "font-family:" + oNode.style.fontFamily + ";";
  1479.  
  1480.   if (oNode.style.fontSize)
  1481.     fontStr += "font-size:" + oNode.style.fontSize + ";";
  1482.  
  1483.   if (oNode.style.fontStyle)
  1484.     fontStr += "font-style:" + oNode.style.fontStyle + ";";
  1485.  
  1486.   if (oNode.style.fontVariant)
  1487.     fontStr += "font-variant:" + oNode.style.fontVariant + ";";
  1488.  
  1489.   if (oNode.style.fontWeight)
  1490.     fontStr += "font-weight:" + oNode.style.fontWeight + ";";
  1491.  
  1492.   return fontStr;
  1493. }
  1494.  
  1495. function f_InheritCellFont(oCell)
  1496. {
  1497.   oCell.children[0].style.fontFamily = oCell.style.fontFamily;
  1498.   oCell.children[0].style.fontSize = oCell.style.fontSize;
  1499.   oCell.children[0].style.fontStyle = oCell.style.fontStyle;
  1500.   oCell.children[0].style.fontVariant = oCell.style.fontVariant;
  1501.   oCell.children[0].style.fontWeight = oCell.style.fontWeight;
  1502. }
  1503.  
  1504. function f_CreateDropDownList(oNode)
  1505. {
  1506.   var oCell = element.document.createElement("td");
  1507.   var szTabIndex = "1";
  1508.   if (oNode.tabIndex != 0)
  1509.     szTabIndex = oNode.getAttribute("tabindex");
  1510.  
  1511.   var szHtml = "<select"
  1512.   if ((szTabIndex != null) && (szTabIndex != ""))
  1513.     szHtml += " tabindex=\"" + szTabIndex + "\"";
  1514.  
  1515.   szHtml += ">";
  1516.   szHtml += oNode.innerHTML;
  1517.   szHtml += "</select>";
  1518.   oCell.innerHTML = szHtml;
  1519.   oCell.children[0].mergeAttributes(oNode);
  1520.   oCell.children[0].disabled = oNode.isDisabled || element.isDisabled;
  1521.   oCell.id = oNode.getAttribute("id");
  1522.   oCell._type = "dropdownlist";
  1523.   oCell.noWrap = "true";
  1524.   var changeScript = oNode.getAttribute("onchange");
  1525.   if (changeScript != null)
  1526.     oCell.children[0].onchange = function() { eval(changeScript) };
  1527.  
  1528.   var szDefaultStyle = oNode.getAttribute("defaultStyle");
  1529.   var fontStr = f_CreateFontString(oNode);
  1530.   szDefaultStyle = (szDefaultStyle == null) ? fontStr : fontStr + szDefaultStyle;
  1531.   if (szDefaultStyle != null)
  1532.   {
  1533.     oCell.setAttribute("defaultStyle", szDefaultStyle, 0);
  1534.     oCell.children[0].removeAttribute("defaultStyle", 0);
  1535.   }
  1536.   return oCell;
  1537. }
  1538.  
  1539. function f_ApplyStylesToChildren()
  1540. {
  1541.   var globalDefault = _BuiltInDefaultStyle + ";" + _tbDefaultStyle + ";";
  1542.   var globalHover = _BuiltInHoverStyle + ";" + _tbHoverStyle + ";";
  1543.   var globalSelected = _BuiltInSelectedStyle + ";" + _tbSelectedStyle + ";";
  1544.   var numItems = f_NumItems();
  1545.   var index;
  1546.   for (index = 0; index < numItems; index++)
  1547.   {
  1548.     var item = f_GetItem(index);
  1549.     var isButton = (item._type == "button");
  1550.     var isCheckButton = (item._type == "checkbutton");
  1551.     var hasGroup = (isCheckButton && (item._group != null));
  1552.     var localDefault = item.getAttribute("defaultStyle");
  1553.     var groupStyle = ";";
  1554.     if (item._turnContent)
  1555.       localDefault += ";writing-mode:tb-rl;";
  1556.  
  1557.     if (isButton || isCheckButton)
  1558.     {
  1559.       item._defaultStyle = globalDefault;
  1560.       if (hasGroup && (item._group.szDefaultStyle != null))
  1561.       item._defaultStyle += item._group.szDefaultStyle + ";";
  1562.       item._defaultStyle += localDefault + ";";
  1563.       item._hoverStyle = item._defaultStyle + globalHover;
  1564.       if (hasGroup && (item._group.szHoverStyle != null))
  1565.       item._hoverStyle += item._group.szHoverStyle + ";";
  1566.       item._hoverStyle += item.getAttribute("hoverStyle") + ";";
  1567.       item._selectedStyle = item._defaultStyle + globalSelected;
  1568.       if (hasGroup && (item._group.szSelectedStyle != null))
  1569.       item._selectedStyle += item._group.szSelectedStyle + ";";
  1570.       item._selectedStyle += item.getAttribute("selectedStyle") + ";";
  1571.       f_ApplyNeutralStyle(item);
  1572.     }
  1573.     else if (item._type != "emptygroup")
  1574.     {
  1575.       item.style.cssText = globalDefault + localDefault;
  1576.       if ((item._type == "dropdownlist") || (item._type == "textbox"))
  1577.       f_InheritCellFont(item);
  1578.     }
  1579.   }
  1580. }
  1581.  
  1582. function f_ApplyNeutralStyle(oCell)
  1583. {
  1584.   switch (oCell._type)
  1585.   {
  1586.   case "checkbutton":
  1587.     oCell.style.cssText = (f_IsSelected(oCell)) ? oCell._selectedStyle : oCell._defaultStyle;
  1588.     break;
  1589.   case "button":
  1590.     oCell.style.cssText = oCell._defaultStyle;
  1591.     break;
  1592.   }
  1593. }
  1594.  
  1595. function f_ApplyPressedStyle(oCell)
  1596. {
  1597.   switch (oCell._type)
  1598.   {
  1599.   case "checkbutton":
  1600.     oCell.style.cssText = oCell._selectedStyle;
  1601.     break;
  1602.   case "button":
  1603.     oCell.style.cssText = oCell._selectedStyle;
  1604.     break;
  1605.   }
  1606. }
  1607.  
  1608. function f_ApplyHoverStyle(oCell)
  1609. {
  1610.   switch (oCell._type)
  1611.   {
  1612.   case "checkbutton":
  1613.     oCell.style.cssText = (f_IsSelected(oCell)) ? oCell._selectedStyle : oCell._hoverStyle;
  1614.     break;
  1615.   case "button":
  1616.     oCell.style.cssText = oCell._hoverStyle;
  1617.     break;
  1618.   }
  1619. }
  1620.  
  1621. function f_OnMouseOver()
  1622. {
  1623.   if (_IsSubmitting || !_Ready)
  1624.     return;
  1625.  
  1626.   if (_bDragging)
  1627.     return;
  1628.  
  1629.   var oCell = f_FindSurroundingCell(event.srcElement);
  1630.   if ((oCell != null) && !oCell.contains(event.fromElement))
  1631.   {
  1632.     if (!f_Interactable(oCell) || oCell.isDisabled)
  1633.       return;
  1634.  
  1635.     if (_oInteractNode != null)
  1636.     {
  1637.       if (_oInteractNode == oCell)
  1638.         f_ApplyPressedStyle(oCell);
  1639.     }
  1640.     else
  1641.     {
  1642.       f_ApplyHoverStyle(oCell);
  1643.     }
  1644.   }
  1645. }
  1646.  
  1647. function f_OnMouseOut()
  1648. {
  1649.   if (_IsSubmitting || !_Ready)
  1650.     return;
  1651.  
  1652.   if (_bDragging)
  1653.     return;
  1654.  
  1655.   var oCell = f_FindSurroundingCell(event.srcElement);
  1656.   if ((oCell != null) && !oCell.contains(event.toElement))
  1657.   {
  1658.     if (!f_Interactable(oCell) || oCell.isDisabled)
  1659.       return;
  1660.     if (_oInteractNode != null)
  1661.     {
  1662.       if (_oInteractNode == oCell)
  1663.         f_ApplyHoverStyle(oCell);
  1664.     }
  1665.     else
  1666.     {
  1667.       f_ApplyNeutralStyle(oCell);
  1668.     }
  1669.   }
  1670. }
  1671.  
  1672. function f_OnMouseDown()
  1673. {
  1674.   if (_IsSubmitting || !_Ready)
  1675.     return;
  1676.  
  1677.   if (event.button != 1)
  1678.     return;
  1679.  
  1680.   var oCell = f_FindSurroundingCell(event.srcElement);
  1681.   if ((oCell != null) && (f_Interactable(oCell)))
  1682.   {
  1683.     f_SetCapture();
  1684.     if (oCell.isDisabled)
  1685.       return;
  1686.     f_ApplyPressedStyle(oCell);
  1687.     _oInteractNode = oCell;
  1688.   }
  1689.   else if (f_IsMoveable())
  1690.   {
  1691.     if ((oCell == null) ||
  1692.     (oCell._type == "gripper"))
  1693.     {
  1694.       f_SetCapture();
  1695.       f_StartDrag();
  1696.     }
  1697.   }
  1698. }
  1699.  
  1700. function f_OnMouseUp()
  1701. {
  1702.   if (_IsSubmitting || !_Ready)
  1703.     return;
  1704.  
  1705.   if (event.button != 1)
  1706.     return;
  1707.  
  1708.   f_ReleaseCapture();
  1709.   if (_oInteractNode != null)
  1710.   {
  1711.     f_ApplyNeutralStyle(_oInteractNode);
  1712.     _oInteractNode = null;
  1713.   }
  1714.  
  1715.   f_StopDrag();
  1716.   f_OnMouseOver();
  1717. }
  1718.  
  1719. function f_OnKeyUp()
  1720. {
  1721.   if (_IsSubmitting || !_Ready)
  1722.     return;
  1723.  
  1724.   if ((event.srcElement.accessKey != null) && event.altKey &&
  1725.           (event.srcElement.accessKey.toUpperCase().charCodeAt() == event.keyCode))
  1726.   {
  1727.     event.srcElement.click();
  1728.   }
  1729.   else
  1730.   {
  1731.     switch (event.keyCode)
  1732.     {
  1733.     case 13:
  1734.     case 32:
  1735.       var oCell = f_FindSurroundingCell(event.srcElement);
  1736.       if (oCell != null)
  1737.       {
  1738.         _KeyboardClick = true;
  1739.         oCell.click();
  1740.       }
  1741.       break;
  1742.     }
  1743.   }
  1744. }
  1745.  
  1746. function f_StartDrag()
  1747. {
  1748.   _nLastScreenX = event.screenX;
  1749.   _nLastScreenY = event.screenY;
  1750.   _nLastClientX = event.clientX;
  1751.   _nLastClientY = event.clientY;
  1752.   _bDragging = true;
  1753. }
  1754.  
  1755. function f_StopDrag()
  1756. {
  1757.   _bDragging = false;
  1758. }
  1759.  
  1760. function f_Least (a, b, c, d)
  1761. {
  1762.   return ((a < b) && (a < c) && (a < d));
  1763. }
  1764.  
  1765. function f_Drag()
  1766. {
  1767.   if (!_bDragging || (event.button != 1))
  1768.   {
  1769.     return;
  1770.   }
  1771.  
  1772.   var nNewLeft = offsetLeft + event.screenX - _nLastScreenX;
  1773.   var nNewTop = offsetTop + event.screenY - _nLastScreenY;
  1774.   _nLastScreenX = event.screenX;
  1775.   _nLastScreenY = event.screenY;
  1776.   var oBody = f_FindSurroundingBody();
  1777.  
  1778.   if (oBody == null)
  1779.     return;
  1780.  
  1781.   var nDeltaLeft = (offsetLeft + event.clientX) - oBody.scrollLeft;
  1782.   var nDeltaTop = (offsetTop + event.clientY) - oBody.scrollTop;
  1783.   var nDeltaRight = (oBody.scrollLeft + oBody.clientWidth) - (offsetLeft + event.clientX);
  1784.   var nDeltaBottom = (oBody.scrollTop + oBody.clientHeight) - (offsetTop + event.clientY);
  1785.   var nMaxDelta = 10;
  1786.  
  1787.   if (f_IsDockable() &&
  1788.       ((nDeltaLeft <= nMaxDelta) || (nDeltaTop <= nMaxDelta) || (nDeltaBottom <= nMaxDelta) || (nDeltaRight <= nMaxDelta)))
  1789.   {
  1790.     if ((!_bDocked && (nDeltaTop <= nMaxDelta)) ||
  1791.         (_bDocked && (_szDockedLocation != "top") && f_Least(nDeltaTop, nDeltaBottom, nDeltaLeft, nDeltaRight)))
  1792.     {
  1793.       if (!_bDocked)
  1794.         _PreDockOrientation = orientation;
  1795.  
  1796.       f_ReleaseCapture();
  1797.       _oTable.releaseCapture();
  1798.       orientation = "horizontal";
  1799.       f_SetCapture();
  1800.       style.removeExpression("height");
  1801.       style.height = "";
  1802.       style.setExpression("left", "scrollLeft-scrollLeft+document.body.scrollLeft", "JavaScript");
  1803.       style.setExpression("top", "scrollTop-scrollTop+document.body.scrollTop", "JavaScript");
  1804.       style.setExpression("width", "document.body.clientWidth");
  1805.       _bDocked = true;
  1806.       _szDockedLocation = "top";
  1807.     }
  1808.     else if ((!_bDocked && (nDeltaLeft <= nMaxDelta)) ||
  1809.         (_bDocked && (_szDockedLocation != "left") && f_Least(nDeltaLeft, nDeltaTop, nDeltaBottom, nDeltaRight)))
  1810.     {
  1811.       if (!_bDocked)
  1812.         _PreDockOrientation = orientation;
  1813.  
  1814.       f_ReleaseCapture();
  1815.       orientation = "vertical";
  1816.       f_SetCapture();
  1817.       style.removeExpression("width");
  1818.       style.width = "";
  1819.       style.height = oBody.clientHeight;
  1820.       style.setExpression("left", "scrollLeft-scrollLeft+document.body.scrollLeft", "JavaScript");
  1821.       style.setExpression("top", "scrollTop-scrollTop+document.body.scrollTop", "JavaScript");
  1822.       style.setExpression("height", "document.body.clientHeight");
  1823.       _bDocked = true;
  1824.       _szDockedLocation = "left";
  1825.     }
  1826.     else if ((!_bDocked && (nDeltaBottom <= nMaxDelta)) ||
  1827.         (_bDocked && (_szDockedLocation != "bottom") && f_Least(nDeltaBottom, nDeltaTop, nDeltaLeft, nDeltaRight)))
  1828.     {
  1829.       if (!_bDocked)
  1830.         _PreDockOrientation = orientation;
  1831.  
  1832.       f_ReleaseCapture();
  1833.       orientation = "horizontal";
  1834.       f_SetCapture();
  1835.       style.removeExpression("height");
  1836.       style.height = "";
  1837.       style.setExpression("left", "scrollLeft-scrollLeft+document.body.scrollLeft", "JavaScript");
  1838.       style.setExpression("top", "scrollTop-scrollTop+document.body.scrollTop+document.body.clientHeight-offsetHeight", "JavaScript");
  1839.       style.setExpression("width", "document.body.clientWidth");
  1840.       _bDocked = true;
  1841.       _szDockedLocation = "bottom";
  1842.     }
  1843.     else if ((!_bDocked && (nDeltaRight <= nMaxDelta)) ||
  1844.         (_bDocked && (_szDockedLocation != "right") && f_Least(nDeltaRight, nDeltaTop, nDeltaBottom, nDeltaLeft)))
  1845.     {
  1846.       if (!_bDocked)
  1847.         _PreDockOrientation = orientation;
  1848.  
  1849.       f_ReleaseCapture();
  1850.       orientation = "vertical";
  1851.       f_SetCapture();
  1852.       style.removeExpression("width");
  1853.       style.width = "";
  1854.       style.height = oBody.clientHeight;
  1855.       style.setExpression("left", "scrollLeft-scrollLeft+document.body.scrollLeft+document.body.clientWidth-offsetWidth", "JavaScript");
  1856.       style.setExpression("top", "scrollTop-scrollTop+document.body.scrollTop", "JavaScript");
  1857.       style.setExpression("height", "document.body.clientHeight");
  1858.       _bDocked = true;
  1859.       _szDockedLocation = "right";
  1860.     }
  1861.   }
  1862.   else if (_bDocked)
  1863.   {
  1864.     f_ReleaseCapture();
  1865.     orientation = _PreDockOrientation;
  1866.     _PreDockOrientation = "";
  1867.     f_SetCapture();
  1868.     style.removeExpression("left");
  1869.     style.removeExpression("top");
  1870.     style.removeExpression("width");
  1871.     style.removeExpression("height");
  1872.     style.width = "";
  1873.     style.height = "";
  1874.     style.left = offsetLeft + (event.clientX - _nLastClientX);
  1875.     style.top = offsetTop + (event.clientY - _nLastClientY);
  1876.     _bDocked = false;
  1877.   }
  1878.   else if (!_bDocked)
  1879.   {
  1880.     style.left = nNewLeft;
  1881.     style.top = nNewTop;
  1882.   }
  1883. }
  1884.  
  1885.  
  1886. function f_SelectItem(oCell)
  1887. {
  1888.   if (!f_Interactable(oCell))
  1889.     return;
  1890.  
  1891.   if (oCell._type == "checkbutton")
  1892.   {
  1893.     if (!f_IsSelected(oCell))
  1894.     {
  1895.       f_CheckButton(oCell);
  1896.     }
  1897.     else if ((oCell._group == null) || (!oCell._group.bForceSel))
  1898.     {
  1899.       f_SetSelected(oCell, false);
  1900.       if (oCell._group != null)
  1901.       {
  1902.         oCell._group.oSelected = null;
  1903.       }
  1904.       f_FireCheckChange(oCell);
  1905.     }
  1906.  
  1907.     if (_KeyboardClick)
  1908.       f_ApplyNeutralStyle(oCell);
  1909.     else
  1910.       f_ApplyHoverStyle(oCell);
  1911.   }
  1912.   f_FireButtonClick(oCell);
  1913. }
  1914.  
  1915. function f_OnClick()
  1916. {
  1917.   if (_IsSubmitting || !_Ready)
  1918.     return;
  1919.  
  1920.   var oCell = f_FindSurroundingCell(event.srcElement);
  1921.   if ((oCell != null) && (!oCell.isDisabled))
  1922.     f_SelectItem(oCell);
  1923.  
  1924.   _KeyboardClick = false;
  1925. }
  1926.  
  1927. function f_FindSurroundingCell(oNode)
  1928. {
  1929.   while (oNode != null)
  1930.   {
  1931.     if (oNode._type != null)
  1932.     return oNode;
  1933.     oNode = oNode.offsetParent;
  1934.   }
  1935.   return null;
  1936. }
  1937.  
  1938. function f_FindSurroundingBody()
  1939. {
  1940.   var oParent = element.offsetParent;
  1941.   while (oParent.tagName != "BODY")
  1942.   {
  1943.     oParent = oParent.offsetParent;
  1944.     if (oParent == null)
  1945.     return;
  1946.   }
  1947.   return oParent;
  1948. }
  1949.  
  1950. function f_CancelInteractEvents()
  1951. {
  1952.   var oCell = f_FindSurroundingCell(event.srcElement);
  1953.   if (oCell == null)
  1954.   {
  1955.     event.returnValue = false;
  1956.   }
  1957.   else
  1958.   {
  1959.     switch (oCell._type)
  1960.     {
  1961.     case "button":
  1962.     case "checkbutton":
  1963.     case "separator":
  1964.     case "gripper":
  1965.     case "label":
  1966.       event.returnValue = false;
  1967.       break;
  1968.     }
  1969.   }
  1970. }
  1971.  
  1972. function f_FireCheckChange(oCell)
  1973. {
  1974.   evCheckChange.fire(f_CreateEventObject(oCell));
  1975. }
  1976.  
  1977. function f_FireButtonClick(oCell)
  1978. {
  1979.   evButtonClick.fire(f_CreateEventObject(oCell));
  1980. }
  1981.  
  1982. function f_CreateEventObject(oCell)
  1983. {
  1984.   var oEvent= createEventObject();
  1985.   if (oCell != null)
  1986.   {
  1987.     oEvent.srcNode = f_PublicMakeContract(oCell);
  1988.     var nIndex = f_GetIndexFromCell(oCell);
  1989.     if (nIndex >= 0)
  1990.     oEvent.flatIndex = nIndex;
  1991.   }
  1992.   return oEvent;
  1993. }
  1994.  
  1995. function f_GetIndexFromCell(oCell)
  1996. {
  1997.   var oParent = f_GetParent();
  1998.   var nIndex;
  1999.   if (orientation == "vertical")
  2000.   {
  2001.     oCell = oCell.parentElement;
  2002.   }
  2003.   
  2004.   for (nIndex = 0; nIndex < oParent.children.length; nIndex++)
  2005.   {
  2006.     if (oCell.uniqueID == oParent.children[nIndex].uniqueID)
  2007.     {
  2008.       return nIndex;
  2009.     }
  2010.   }
  2011.   return -1;
  2012. }
  2013.  
  2014. function f_SetCapture()
  2015. {
  2016.   f_ReleaseCapture();
  2017.   _oTable.setCapture();
  2018. }
  2019.  
  2020. function f_ReleaseCapture()
  2021. {
  2022.   _oTable.releaseCapture();
  2023. }
  2024.  
  2025. function f_OnStop()
  2026. {
  2027.   if (!_IsSubmitting || (_OnStopCount > 0))
  2028.   {
  2029.     _IsSubmitting = false;
  2030.     element.removeAttribute("_submitting");
  2031.   }
  2032.   _OnStopCount++;
  2033. }
  2034.  
  2035. function f_CleanupEvents()
  2036. {
  2037.   var eventArray = window.__toolbarAttachedEvents;
  2038.   if ((eventArray != null) && (eventArray[0]))
  2039.   {
  2040.     var newArray = new Array(false);
  2041.     for (var i = 1; i < eventArray.length; i++)
  2042.     {
  2043.       if (element.document.all[eventArray[i][0]] == null)
  2044.       {
  2045.         element.document.detachEvent("onstop", eventArray[i][1]);
  2046.       }
  2047.       else
  2048.       {
  2049.         newArray = newArray.concat(new Array(eventArray[i]));
  2050.       }
  2051.     }
  2052.     window.__toolbarAttachedEvents = newArray;
  2053.   }
  2054. }
  2055.  
  2056. function f_AddStopEvent()
  2057. {
  2058.   var eventArray = window.__toolbarAttachedEvents;
  2059.   if (eventArray == null)
  2060.   {
  2061.     eventArray = new Array(false);
  2062.   }
  2063.   element.document.attachEvent("onstop", f_OnStop);
  2064.   eventArray[0] = true;
  2065.   entry = new Array(element.uniqueID, f_OnStop);
  2066.   window.__toolbarAttachedEvents = eventArray.concat(new Array(entry));
  2067. }
  2068.  
  2069. function f_OnDocReady()//it was absent
  2070. {
  2071. }
  2072.  
  2073. </script>
  2074.  
  2075. </public:component>